//定义积分类
class ScorePanel {
    score = 0;//计分
    level = 1;//等级

    scoreEle:HTMLElement;//获取计分元素
    levelEle:HTMLElement;//获取等级元素

    // 定义一个变量限制等级
    maxLevel:number;
    // 定义一个变量，表示多少分升级
    upScore:number;

    constructor(maxLevel:number = 10,upScore:number = 10) {//如果不传，最大值默认就是10
        this.scoreEle = document.getElementById('score')!;
        this.levelEle = document.getElementById('level')!;
        this.maxLevel = maxLevel;
        this.upScore = upScore;
    }
    // 设置一个加分的方法
    addScore(){
        // 让分数增加   每10分升一级
        this.scoreEle.innerHTML = String(++this.score);
        if (this.score%this.upScore === 0) {
            this.levelUP()
        }
    }
    levelUP(){
        if (this.level<this.maxLevel) {
            this.levelEle.innerHTML = String(++this.level);
        }
    }
}
const scorePanel = new ScorePanel(100,2);
for (let index = 0; index < 200; index++) {
    scorePanel.addScore()
}
export default ScorePanel;
console.log(11);
